<?php 
ob_start();

session_start();

$_SESSION['url']=curPageURL();

$page = $_GET['page'];
$srch_val = "search";
include("application/base_class.php");

$base_obj = new BaseClass();

unset($_SESSION['offline']);

//if($base_obj->online_status == "0" && $page !="assignment_manager")  {
if($base_obj->online_status == "0")  {
	unset($_SESSION['user_id']);
	
	echo '<script>location.href="maintenance.php"</script>';
} elseif($base_obj->online_status == "0" && $page =="assignment_manager") {
	$_SESSION['offline'] = 1;
}

/******************** UPDATE ONLINE STATUS ********************/
$session_id = session_id();
$dt = time();
$sql = "update history_login set datetime = '$dt' where session_id = '$session_id' and active = 1";
mysql_query($sql);
/******************** UPDATE ONLINE STATUS ********************/

$act = isset($_GET['act']) ? strtolower($_GET['act']) : "";

switch($page) {
	case 'search':
		$view = "view/search.php";
		break;	
	case 'login':
		$view = "view/login.php";
		break;
	case 'register':
		if($act == "confirm_register") {
			$key = isset($_GET['k']) ? addslashes($_GET['k']) : "";
			$val = $base_obj->confirmRegister($key);
			if ($val == 1)
			{	
				$view = "view/confirm_register_success.php";
			}
			else
				$view = "view/confirm_register_fail.php";
		} else {
			$view = "view/register.php";
		}
		break;
   case 'forgot_password':
		$view = "view/forgot_password.html";
		break;	
	case 'universities':
	if($_GET['view'] =='rate_your_university')
		{
		if($_SESSION['user_id']!="")	
		{
			
		 $view = "view/rate_univ.php";
		}
		
		else
		{
		$view = "view/login.php";
		}
		}
		else
		{
			$view = "view/university.php";
		}
	   if($_GET['view'] =='university_education')
		{
			if($_SESSION['user_id']!="")	
		{
		$view = "view/university_edu.php";	
		 
		}
		else
		{
			$view = "view/login.php";
		}

		}			
		break;	
	case 'jobs':
		switch($_GET['view']) {
			case 'view_job':
				$view = "view/view_jobs.php";
				break;
			case 'view_ad_search':
				$view = "view/view_ad_search.php";
				break;
			case 'apply_job':
				$view = "view/apply_job.php";
				break;	
				
			case 'employment':
				$view = "view/employment.php";
				break;	
				
			case 'advertise_jobs':
			    
				if($_GET['step'] == "2") {
					$view = "view/jobpost_step2.php";
				}
				else if($_GET['step'] == "3") {
					$view = "view/jobpost_step4.php";
				}
				else {
					$view = "view/jobpost_step1.php";
				}
		
		break;	
			default:	
				$view = "view/jobpost_step1.php";
		}
		break;
	case 'books':
	if($_GET['view']== 'sell_books')
	{
		if($_SESSION['user_id']!="")	
		{
			$view = "view/post_books.php";
		}
		else
		{
			$view = "view/login.php";
		}
	}
	else
	{
	$view = "view/books.php";
	}
		break;	
	case 'logon':
		$view = "view/logon.php";
		break;
	case 'search_job':
		$view = "view/search_job.php";
		break;
	case 'view_job':
		$view = "view/view_jobs.php";
		break;
	case 'apply_job':
		$view = "view/apply_job.php";
		break;	
	case 'logout':
		unset($_SESSION['add']);
		$view = "view/logout.php";
		break;	
	case 'contact_us':
		$view = "view/contact_us.html";
		break;
	case 'thanks':
		$view = "view/thanks.php";
		break;
	case 'sub_page':
		$view = "view/sub_page.php";
		break;
	case 'privacy':
		$view = "view/privacy.php";
		break;
	case 'terms':
		$view = "view/terms.php";
		break;	
case 'technology':
	
	    if($_GET['mode'] == "view") {
			$product_id = $_GET['product_id'];
			$view = "view/technology.php";
		}
		else if($_GET['view'] == "technology_news") {
					$view = "view/news.php";
				}
		else if($_GET['view'] == "technology_jobs") {
					$view = "view/tech_job.php";
				
				}		
		else if($_GET['view'] == "news") {
						$view = "view/news.php";
				}				
		
		else {
			$view = "view/technology.php";
		}
		
		break;
	case 'assignment_manager':
	      if($_GET['view'] == "add_assign") {
			  $view = "view/add_assignment.php";
			  break;
		    }
			if($_GET['view'] == "continue_assign") {
				$view = "view/continue_assignment.php";
				break;
			}	
		  if($_GET['view'] == "journal") {
			   $view = "view/journel.php";
		    }
			
		else if($_GET['view'] == "citation") {
			   $view = "view/citation.php";
		    }
			
		else if(($_GET['step'] == "delete") or ($_GET['step'] == "edit")) {
			   $view = "view/journel.php";
		    }
			
		else if($_GET['step']=="generate")
		{
			$view = "view/generate.php";
		}
		
		else if($_GET['view']=="website")
		{
			$view = "view/search_website.php";
		}
		else if($_GET['step']=="generate_website")
		{
			$view = "view/generate_website.php";
		}
		
		else if($_GET['step']=="generate_book")
		{
			$view = "view/generate_book.php";
		}
		else if($_GET['view']=="book")
		{
			$view = "view/ass_book.php";
		}
		else
		{
			unset($_SESSION['file1']);
			unset($_SESSION['file2']);
			unset($_SESSION['file3']);
			unset($_SESSION['file4']);
			unset($_SESSION['file5']);
			unset($_SESSION['file6']);
			unset($_SESSION['file7']);
			unset($_SESSION['file8']);
			unset($_SESSION['file9']);
			unset($_SESSION['file10']);
			$view = "view/assignment_manager.php";
		}
	break;
		
	case 'advt_prod':
		$view = "view/advt_prod.php";
		break;	
	case 'banner_adverts':
		$view = "view/banner_adverts.php";
		break;			
	case 'classifieds':
		if($_GET['view'] == "cat") {
			$cat_id = $_GET['cat_id'];
			$view = "view/classifieds_cat_view.php";
		}
		else if($_GET['view'] == "ad") {
			$cat_id = $_GET['cat_id'];
			$view = "view/classifieds_ad_view.php";
		}
		else if($_GET['view'] == "post_classifieds_ads") {
			if($_SESSION['user_id'] != "") {
				$view = "view/classifieds_post_ads.php";
			}
			else {
				$view = "view/login.php";
			}
		}
		else {
			$view = "view/classifieds.php";
		}
		break;
	case "my_saved_bibliographies":
		$view = "view/my_saved_bibliography.php";
	break;
	case "saved_references":
		$view = "view/my_saved_bibliography.php";
	break;
	default:
		if($page == "") {
			$page = 'home';
		}
		$view = "view/home.php";
		header("location:index.php?page=assignment_manager");
		break;
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>


<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />


<?php
$url = curPageURL();

$curr =$_GET['page'];
$curr=str_replace('_',' ',$curr);
if($url=='http://www.studysage.com.au/' || $url=='http://www.studysage.com.au/index.php')
{
echo '<title>Studysage :: Home</title>';
}
else
{
	echo '<title>Studysage::'.ucfirst($curr).'</title>';
}


$qry = "select * from seo";
$res = $base_obj->exec_query($qry);
$data = $base_obj->fetch_row($res);
echo '<meta name="description" content="'.stripslashes($data['meta_content']).'"/>';
echo '<meta name="keywords" content="'.stripslashes($data['meta_keywords']).'"/> '; 
?>

<link rel="stylesheet" href="css/style.css" type="text/css" />
<link rel="stylesheet" href="css/css.css" type="text/css" />
<link rel="stylesheet" href="css/general.css" type="text/css" media="screen" />
<link rel="stylesheet" type="text/css" href="chromejs/chromestyle.css" />

<script src="js/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="js/popup.js" type="text/javascript"></script>
<!--  <script type="text/javascript" src="chromejs/chrome.js"/></script>-->
<!-- <script type="text/javascript" src="js/cmg_extensions.js"></script> -->
<script type="text/javascript" src="js/jquery.cycle.js"></script>
<script type="text/javascript" src="js/fancyzoom.min.js"></script>
<script type="text/javascript" charset="utf-8">
	$(document).ready(function() {
		//$('div.photo a').fancyZoom({scaleImg: true, closeOnClick: true});
		//$('#medium_box_link').fancyZoom({width:500, height:400});
		
	});
</script>

<script language="javascript" type="text/javascript" src="js/common.js"></script>
</head>
<body>
<!-- Begin Cover -->
<div id="cover" >
<!-- Begin Wrapper -->
<div id="wrapper">
  <!-- Begin Header -->
  <?php include("includes/header.php");?>
  
  <!-- End Header -->
  <?php include($view);?>

 
  <?php include("includes/footer.php");?>
</div>
<!-- End Wrapper -->
</div>
<!-- End Cover -->
 <?php
function curPageURL() {
 $pageURL = 'http';
 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
 $pageURL .= "://";
 if ($_SERVER["SERVER_PORT"] != "80") {
  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
 } else {
  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
 }
 return $pageURL;
}

ob_end_flush();
?>
<div id="loadingDataAjax" style="position: absolute; right: 10px; top: 10px; display: none;background-color:white;z-index:99999">
				<img src="images/ajax-loader.gif" border="0" />
			</div>
			<div id="divEmptyData" style="display:none"></div>
</body>
</html>